<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../0_assets/js/mustache.min.js"></script>
</head>
<body>
    <ul class="list"></ul>
    <script>
        let list = document.querySelector('.list');
        let data = {
            arr:[
                {
                    name:'mikaisa1',
                    age:18,
                    hobbies:['学习','画画']
                },
                {
                    name:'mikaisa2',
                    age:23,
                    hobbies:['上厕所','画画']
                },
                {
                    name:'mikaisa3',
                    age:21,
                    hobbies:['吃饭','画画']
                },
            ]
        };

        // 数组的嵌套听上去有点吓人，但是很简单的，你看，是不是很容易理解. 数组嵌套，那我们的模板语法也按照规矩嵌套就行了
        let templateStr = `
        {{#arr}}
            <li>
                <h2>{{age}}岁的{{name}}的爱好有:</h2>
                <ul>
                    {{#hobbies}}
                        <li>{{.}}</li>
                    {{/hobbies}}
                </ul>
            </li>
        {{/arr}}
        `;
        list.innerHTML = mustache.render(templateStr,data);


    </script>
</body>
</html>